﻿using System;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace NTmdb.TestProject
{
    /// <summary>
    ///     This is a test class for TmdbCreateMovieListRequestTest and is intended
    ///     to contain all TmdbCreateMovieListRequestTest Unit Tests
    /// </summary>
    [TestClass]
    public class TmdbCreateMovieListRequestTest
    {
        /// <summary>
        ///     A test for TmdbCreateMovieListRequest Constructor
        /// </summary>
        [TestMethod]
        public void TmdbCreateMovieListRequestConstructorTest()
        {
            var target = new TmdbCreateMovieListRequest();
            Assert.IsNotNull( target );
        }

        /// <summary>
        ///     A test for Description
        /// </summary>
        [TestMethod]
        public void DescriptionTest()
        {
            var target = new TmdbCreateMovieListRequest();
            string expected = Guid.NewGuid().ToString();
            target.Description = expected;
            string actual = target.Description;
            Assert.AreEqual( expected, actual );
        }

        /// <summary>
        ///     A test for Language
        /// </summary>
        [TestMethod]
        public void LanguageTest()
        {
            var target = new TmdbCreateMovieListRequest();
            string expected = Guid.NewGuid().ToString();
            target.Language = expected;
            string actual = target.Language;
            Assert.AreEqual( expected, actual );
        }

        /// <summary>
        ///     A test for Name
        /// </summary>
        [TestMethod]
        public void NameTest()
        {
            var target = new TmdbCreateMovieListRequest();
            string expected = Guid.NewGuid().ToString();
            target.Name = expected;
            string actual = target.Name;
            Assert.AreEqual( expected, actual );
        }

        /// <summary>
        ///     A test for Serialize & Deserialize
        /// </summary>
        [TestMethod]
        public async Task SerializeDeserializeTest()
        {
            var target = new TmdbCreateMovieListRequest
                {
                    Description = Guid.NewGuid().ToString(),
                    Name = Guid.NewGuid().ToString(),
                    Language = Guid.NewGuid().ToString()
                };
            var json = await target.Serialize();
            var expectedJson = String.Format(
                "{0}\"name\":\"{1}\",\"description\":\"{2}\",\"language\":\"{3}\"{4}", "{", target.Name, target.Description, target.Language, "}");
            Assert.AreEqual( expectedJson, json );

            var actual = await target.DeserializeJson<TmdbCreateMovieListRequest>(json);
            Assert.AreEqual( target.Description, actual.Description );
            Assert.AreEqual(target.Name, actual.Name);
            Assert.AreEqual(target.Language, actual.Language);
        }
    }
}